<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>bmap async</title>
    <style>
      body,
      html,
      #allmap {
        width: 100%;
        height: 100%;
        overflow: hidden;
        margin: 0;
        font-family: '微软雅黑';
      }
    </style>
  </head>
  <body>
    <div id="allmap"></div>
  </body>
</html>
<!-- <script
  type="text/javascript"
  src="https://api.map.baidu.com/api?type=webgl&v=1.0&ak=CPxHyHH5XD8mUnmRPbv9BehycOEklp34"
></script> -->
<script>
  const init = async () => {
    const bmap = new BMapGL.Map('allmap') // 创建地图实例
    const point = new BMapGL.Point(116.404, 39.915) // 经纬度
    bmap.centerAndZoom(point, 6) // 设置中心点坐标和地图级别
  }
  const mapUrl = 'https://api.map.baidu.com/api?type=webgl&v=1.0&ak=CPxHyHH5XD8mUnmRPbv9BehycOEklp34&callback=init' // 地图api地址
  // 页面加载完成
  window.onload = function () {
    const script = document.createElement('script')
    script.src = mapUrl
    document.head.appendChild(script)
  }
</script>
